class object {
  String objectName;
  String oid;
  String gid;
  String value;
  String commentary;

  object({
     this.objectName = '苗仁豪',
     this.oid = '6666',
     this.gid = '1002',
     this.value = '0',
     this.commentary ='无',
  });

  // 对象转JSON
  Map<String, dynamic> toJson() {
    return {
      'objectName': objectName,
      'oid': oid,
      'gid': gid,
      'value': value,
      'commentary': commentary,
    };
  }

  static final Map<String, String> _gidMapping = {
      "1000":"管理员组",
      "1001":"裁剪车间",
      "1002":"张送真",
      "1003":"包装组",
      "1005":"销售员",
      "1006":"刘洋",
  };

  static String? getGroupName(String gid) {
    return _gidMapping[gid];
  }

 static String? findKeyByValue(String targetValue) {
  final entry = _gidMapping.entries.firstWhere(
    (entry) => entry.value == targetValue,
    orElse: () => const MapEntry("","10001"),
  );
  if (entry.key.isNotEmpty) {
    return entry.key;
  } else {
    return null; // 未找到匹配的键
  }
}
  // JSON转对象
  factory object.fromJson(Map<String, dynamic> json) {
    return object(
      objectName: json['objectName'].toString(),
      oid: json['oid'].toString(),
      gid: json['gid'].toString(),
      value: json['value'].toString(),
      commentary: json['commentary'].toString(),
    );
  }
}
